{% extends 'base.html' %} {% load staticfiles %} {% block title %}服务器:{{ asset.name }}{% endblock %} {% block css %}

<!-- Theme style -->
<link rel="stylesheet" href="{% static 'dist/css/AdminLTE.min.css' %}">
<!-- AdminLTE Skins. Choose a skin from the css/skins folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="{% static 'dist/css/skins/_all-skins.min.css' %}"> {% endblock %} {% block content %}

<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>服务器详细</h1>
  <ol class="breadcrumb">
    <li><a href="{% url 'index' %}"><i class="fa fa-dashboard"></i> 主页</a></li>
    <li>资产总表</li>
    <li class="active">服务器详细</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

  <!-- Default box -->
  <div class="box">
    <div class="box-body">  
      <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
          <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="false">基本信息</a></li>
          <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">更新日志</a></li>
        </ul>
        <div class="tab-content">
          <div class="tab-pane active" id="tab_1">
            <div class="row">
              <div class="col-xs-2 text-right">固资编号:</div>
              <div class="col-xs-4">{{ asset.name }}</div>
              <div class="col-xs-2 text-right">SN:</div>
              <div class="col-xs-4">{{ asset.sn }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">维护人:</div>
              <div class="col-xs-4">{{ asset.operation|default:'' }}</div>
              <div class="col-xs-2 text-right">状态:</div>
              <div class="col-xs-4">{{ asset.get_status_display }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">服务器类型:</div>
              <div class="col-xs-4">{{ server.get_server_type_display }}</div>
              <div class="col-xs-2 text-right">管理IP:</div>
              <div class="col-xs-4">{{ asset.manage_ip|default:'' }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">业务线:</div>
              <div class="col-xs-4">{{ asset.get_business_unit_display|default:'' }}</div>
              <div class="col-xs-2 text-right">用途:</div>
              <div class="col-xs-4">{{ asset.application }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">厂商:</div>
              <div class="col-xs-4">{{ asset.manufacturer|default:'' }}</div>
              <div class="col-xs-2 text-right">型号:</div>
              <div class="col-xs-4">{{ asset.modelnumber|default:'' }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">机房:</div>
              <div class="col-xs-4">{{ asset.idc|default:'' }}</div>
              <div class="col-xs-2 text-right">高度(U):</div>
              <div class="col-xs-4">{{ asset.high|default:'' }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">机房管理单元:</div>
              <div class="col-xs-4">{{ asset.machineRoom|default:'' }}</div>
              <div class="col-xs-2 text-right">机架:</div>
              <div class="col-xs-4">{{ asset.cabinet|default:'N/A' }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">备注:</div>
              <div class="col-xs-6">{{ asset.memo|default:'' }}</div>
            </div>
            <br>
            <p style=" margin:0 auto; text-align:center;">
              <button class="btn btn-default " align="center" data-toggle="modal" data-target="#myModal">修改</button> 
            </p>
            <h4><b>关联交换机:</b></h4>
            <table border="1" class="table  table-responsive" style="solid">
              <thead>
                <tr>
                  <th>设备</th>
                  <th>设备端口</th>
                </tr>
              </thead>
              <tbody>
                {% for port in port %}
                <tr>
                  <td>{{ port.networkdevice.hostname|default:'N/A' }}</td>
                  <td>{{ port.name|default:'N/A' }}</td>
                </tr>
                {% empty %}
                <tr>没有互联设备！</tr>
                {% endfor %}
              </tbody>
            </table>
            <br>
            <h4><b>IP地址:</b></h4>
            <table border="1" class="table  table-responsive" style="solid">
              <thead>
                <tr>
                  <th>IP</th>
                  <th>运营商</th>
                  <th>网关</th>
                </tr>
              </thead>
              <tbody>
                {% for ipaddress in ipaddress %}
                <tr>
                  <td>{{ ipaddress.name|default:'N/A' }}</td>
                  <td>{{ ipaddress.ipnet.isp|default:'N/A' }}</td>
                  <td>{{ ipaddress.ipnet.gw_ip|default:'N/A' }}</td>
                </tr>
                {% empty %}
                <tr>没有IP！</tr>
                {% endfor %}
              </tbody>
            </table>
    <form class="form-horizontal content_size" action="{% url 'serverdetail' asset.id %}" method="post">
      {% csrf_token %}
      <div class="modal fade" id='myModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
              <h4 class="modal-title">服务器信息修改</h4>
            </div>
            <div class="modal-body">
              <form class="form-horizontal" role="form">
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">固资编号:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" type="text" name='name' placeholder= {{ asset.name }} readonly >
                </div>  
                <label for="modify" class="col-sm-2 control-label">SN:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='sn' value= {{ asset.sn }}>
                </div>
              </div>  
              <div class="form-group">    
                <label for="modify" class="col-sm-2 control-label">设备高度(U):</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='high' value= {{ asset.high|default:"" }}>
                </div>
                <label for="modify" class="col-sm-2 control-label">机柜:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='cabinet' value= {{ asset.cabinet|default:"" }}>
                </div>  
              </div>
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">业务线:</label>
                <div class="col-sm-3">
                  <select class="form-control" name='business_unit'>
                    <option value='0' {% if asset.business_unit == 0 %} selected="selected" {% endif %}>领骏</option>
                    <option value='1' {% if asset.business_unit == 1 %} selected="selected" {% endif %}>驰联</option>
                  </select>
                </div>  
                <label for="modify" class="col-sm-2 control-label">状态:</label>
                <div class="col-sm-3">
                  <select class="form-control" name='status'>
                    <option value='0' {% if asset.status == 0 %} selected="selected" {% endif %}>运营</option>
                    <option value='1' {% if asset.status == 1 %} selected="selected" {% endif %}>闲置</option>
                    <option value='2' {% if asset.status == 2 %} selected="selected" {% endif %}>待启用</option>
                    <option value='3' {% if asset.status == 3 %} selected="selected" {% endif %}>故障</option>
                    <option value='4' {% if asset.status == 4 %} selected="selected" {% endif %}>备用</option>
                  </select>
                </div>  
              </div>
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">型号:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='modelnumber' value= '{{ asset.modelnumber|default:"" }}'>
                </div>  
                <label for="modify" class="col-sm-2 control-label">厂商:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='manufacturer' value= {{ asset.manufacturer|default:"" }}>
                </div>  
              </div>
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">管理IP:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='manage_ip' value= {{ asset.manage_ip|default:"" }}>
                </div>  
                <label for="modify" class="col-sm-2 control-label">维护人:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='operation' value= {{ asset.operation|default:"" }}>
                </div>
              </div>
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">机房:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" id='datacenter' name='idc' value= {{ asset.idc|default:"" }}>
                </div>
                <label for="modify" class="col-sm-2 control-label">机房管理单元:</label>
                <div class="col-sm-3">
                  <select class="form-control" id='machineroom' name='machineRoom'>
                   <option value='' {% if asset.machineRoom == '' %} selected="selected" {% endif %}>请选择</option>
                   {% for machineroom in machineroom %}
                   <option value={{ machineroom }}  {% if asset.machineRoom == machineroom %} selected="selected" {% endif %}>{{ machineroom }}</option>
                   {% endfor %}
                  </select>
                </div>  
              </div>
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">用途:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='application' value= {{ asset.application|default:"" }}>
                </div>  
                <label for="modify" class="col-sm-2 control-label">备注:</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name='memo' value= {{ asset.memo }}>
                </div>  
              </div>
              <div class="form-group">
                <label for="modify" class="col-sm-2 control-label">修改原因:<font color='#ff0000'>*</font></label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name='reason' required>
                </div>  
              </div>
            </form>
          </div>
        <div class="modal-footer">
          <button type="submit" name="submit" value="server_edit" class="btn btn-primary">确认</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        </div>
      </div>
      </div>
    </div>
  </form>
</div>
        
      <!-- /.tab-pane tab_1 -->
      <div class="tab-pane" id="tab_2">
        <h4><b>{{ asset.name }} 日志信息:</b></h4>
        <table id="eventlog_table" border="1" class="display table table-bordered table-striped" >
            <thead>
              <tr>
                  <th>类型</th>
                  <th>详细内容</th>
                  <th>操作原因</th>
                  <th>操作时间</th>
                  <th>操作人</th>
              </tr>
            </thead>
            <tbody>
              {% for log in eventlog %}
              <tr>
                <td id="log_event_type">{{ log.get_event_type_display }}</td>
                <td id="log_detail">{{ log.detail }}</td>
                <td id="log_reason">{{ log.reason }}</td>
                <td id="log_date">{{ log.date|date:"Y-m-d  H:i:s" }}</td>
                <td id="log_user">{{ log.user }}</td>
              </tr>
              {% empty %}
              <tr>没有日志信息！</tr>
              {% endfor %}
            </tbody>
        </table>
      </div>
      <!-- /.tab-pane tab_2 -->
      </div>
      </div>
    </div>
    <!-- /.box-body -->
    <div class="box-footer">
      <i class="fa fa-angle-double-left"></i>&nbsp;&nbsp;<a href="{% url 'index' %}"><strong>返回资产列表页</strong></a>
    </div>
    <!-- /.box-footer-->
  </div>
  <!-- /.box -->

</section>
<!-- /.content -->
{% endblock %}
{% block page-script %}
<script src="{% static 'js/mygetdata.js' %}"></script>
  <link rel="stylesheet" href="{% static 'css/jquery-ui.min.css' %}">
 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
{% endblock %}
